package conexion;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;

public class MoverContrato {

    public static void moverContrato(String id){    
		URL urlBuyUser;
		HttpsURLConnection connectionBuyUser = null;
		String lineBuyUser="0";
		String setCookie = Conexion.EASW_KEY + "; " + Conexion.easf_sess_com + "; FUTWebPhishing" + Conexion.FUTWebPhishing;
		String data="{\"itemData\":[{\"pile\":\"trade\",\"id\":\""+id+"\"}]}";
     
		try{
			urlBuyUser = new URL("https://utas.fut.ea.com/ut/game/fifa13/item");
			connectionBuyUser = (HttpsURLConnection)urlBuyUser.openConnection();
			connectionBuyUser.setRequestMethod("POST");
			connectionBuyUser.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31");connectionBuyUser.setRequestProperty("Cookie", setCookie);
			connectionBuyUser.setRequestProperty("Content-Type", "application/json");       
			connectionBuyUser.setRequestProperty("X-UT-SID", Conexion.XUTSID);       
			connectionBuyUser.setRequestProperty("X-HTTP-Method-Override", "PUT");
			connectionBuyUser.setUseCaches (false);connectionBuyUser.setDoInput(true);connectionBuyUser.setDoOutput(true);          
			              
			//Send request
			DataOutputStream wrBuyUser = new DataOutputStream (connectionBuyUser.getOutputStream ());
			wrBuyUser.writeBytes (data);
			wrBuyUser.flush ();
			wrBuyUser.close ();
			                       
			//Get Response  
			InputStream isBuyUser = connectionBuyUser.getInputStream();             
			BufferedReader rdBuyUser = new BufferedReader(new InputStreamReader(isBuyUser));                
			lineBuyUser = rdBuyUser.readLine();             
			//System.out.println("\n"+lineBuyUser);

			Thread.sleep(500);
			
			Vender.tradePile();
		
		}catch(Exception e){}
	}

}
